class JQuery {
  constructor(selector) {
    const elems = document.querySelectorAll(selector);
    const length = elems.length;
    for (let i = 0; i < length; i++) {
      this[i] = elems[i];
    }
    //    类数组 类似于数组 但是不是数组
    this.length = length;
  }
  get(index) {
    return this[index];
  }
  each(fn) {
    for (let i = 0; i < this.length; i++) {
      fn(this[i], i);
    }
  }
  on(type, fn) {
    return this.each((elem, index) => {
      elem.addEventListener(type, fn, false);
    });
  }
}

// 扩展的话
JQuery.prototype.dialog = (info) => {
  alert(info);
};

class MyJQuery extends JQuery {
  constructor(selector) {
    super(selector);
  }
  me() {
    console.log("继承");
  }
}
